Conversation
| /* Ignore errno from prctl */ | ||
| /* See: https://bugzilla.redhat.com/show_bug.cgi?id=2302746 */ | ||
| errno = old_errno; | ||
| int res = prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)addr, size, name); |
There was a problem hiding this comment.
I think that we still need to restore errno because it will be called just after mmap is created for builin case
There was a problem hiding this comment.
_PyAnnotateMemoryMap() is only called when a memory allocation succeed. Would you mind to elaborate in which case it matters to preserve the previous errno?
There was a problem hiding this comment.
mmap called -> errno 0 -> _PyAnnotateMemoryMap called -> errno non 0 -> propagate errno?
Since _PyAnnotateMemoryMap is optional, I would like to avoid this errno is exposed to caller.
There was a problem hiding this comment.
In Modules/mmapmodule.c, errno is only used if mmap() fails:
Py_BEGIN_ALLOW_THREADS
m_obj->data = mmap(NULL, map_size, prot, flags, fd, offset);
Py_END_ALLOW_THREADS
int saved_errno = errno;
if (devzero != -1) {
close(devzero);
}
if (m_obj->data == (char *)-1) {
m_obj->data = NULL;
Py_DECREF(m_obj);
errno = saved_errno;
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
#ifdef MAP_ANONYMOUS
if (m_obj->flags & MAP_ANONYMOUS) {
(void)_PyAnnotateMemoryMap(m_obj->data, map_size, "cpython:mmap");
}
#endif
m_obj->access = (access_mode)access;
return (PyObject *)m_obj;I don't see what you mean by propagate errno, since errno is not used when _PyAnnotateMemoryMap() is called.
No description provided.